'use strict';

function compute_median(collection) {
  let result;
  function sortnumber(a,b){
    return a-b;
  }
  collection.sort(sortnumber);
  let l=collection.length;
  if(l%2==1){
    result=collection[(l+1)/2-1];
  }
  else{
    result=(collection[l/2-1]+collection[l/2])*0.5; 
  }
  return result;
}

module.exports = compute_median;


